
from distutils.core import setup
import py2exe

import os

obfs = []
for file in os.listdir('C:\\Program Files\\OpenBabel-2.2.3'):
	if file.endswith('obf'):
		obfs.append('C:\\Program Files\\OpenBabel-2.2.3\\'+file)

library = ['library/'+file for file in os.listdir('library') if not file == ".svn"]

obfs.append("C:\\Program Files\\OpenBabel-2.2.3\\"+"libstdinchi.dll")
obfs.append("C:\\Program Files\\OpenBabel-2.2.3\\"+"libxml2.dll")
obfs.append("C:\\Program Files\\OpenBabel-2.2.3\\"+"iconv.dll")

docs = ['docs/getting started.html', 'docs/user manual.html', 'docs/style.css', 'docs/collection.qhc', 'docs/docs.qch', 'docs/about.txt', 'docs/editor manual.html', 'docs/smeDocs.qch']

qtassistantFiles = ["C:\\Qt\\4.6.1\\bin\\assistant.exe", "C:\\Qt\\4.6.1\\bin\\QtCLucene4.dll", "C:\\Qt\\4.6.1\\bin\\QtHelp4.dll", "C:\\Qt\\4.6.1\\bin\\QtSQL4.dll", "C:\\Qt\\4.6.1\\bin\\QtXML4.dll", "C:\\Qt\\4.6.1\\bin\\QtWebKit4.dll", "C:\\Qt\\4.6.1\\bin\\phonon4.dll", "C:\\Qt\\4.6.1\\bin\\QtXmlPatterns4.dll"]
plugins = ["C:\\Qt\\4.6.1\\plugins\\sqldrivers\\qsqlite4.dll"]

files = [('.', ['COPYING', 'README.txt', 'IconCOPYING']), ('.', obfs), ('common', ["common/elements.yaml", "common/test.ico"]), ('docs', docs), ('.', qtassistantFiles), ('plugins/sqldrivers', plugins), ('library', library)]

options = {"py2exe" : {"includes" : ["sip", "PyQt4.QtNetwork"], "excludes": ["Tkconstants", "Tkinter", "tcl", "_ssl", 'pyreadline', 'difflib', 'doctest', 'locale', 'optparse', 'pickle', 'calendar', 'email']}}

setup(name="OriginDB", version="1.10", author="Jason Power", windows=[{'script':'main.py'}, {'script':'userAdd.py'}], data_files=files, options=options)

f = open("dist/qt.conf", 'w')
f.write(
"""
[Paths]
Plugins = plugins
Binaries = .
""")
f.close()

try:
	os.remove("dist/OriginDB.exe")
except WindowsError:
	pass

os.rename("dist/main.exe", "dist/OriginDB.exe")


os.system('"C:\\Program Files\\Inno Setup 5\\ISCC.exe" setup.iss')
